package com.jbit.dm_160.controller;

import com.jbit.dm_160.model.dto.SchedulerSeatPriceDTO;
import com.jbit.dm_160.model.vo.SearchSchedulerVO;
import com.jbit.dm_160.service.SchedulerSeatService;
import com.jbit.dm_160.utils.ResponseEntity;
import com.jbit.dm_160.utils.ResponseUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/scheduler/api")
public class SchedulerController {
    @Resource
    private SchedulerSeatService schedulerSeatService;
    @PostMapping("/p/queryOriginalCinemaSeatArray")
    public ResponseEntity queryOriginalCinemaSeatArray(@RequestBody SearchSchedulerVO searchSchedulerVO){
        List<String> list = schedulerSeatService.getSeatArrayByScheduleId(searchSchedulerVO.getScheduleId());
        Map<String,Object> map = new HashMap<>();
        map.put("cinemaId",searchSchedulerVO.getCinemaId());
        map.put("seatArray",list);
        return ResponseUtils.sendSuccess(map);
    }

    @PostMapping("/p/queryCinemaSeatArrayByScheduleId")
    public ResponseEntity<SchedulerSeatPriceDTO> queryCinemaSeatArrayByScheduleId(@RequestBody SearchSchedulerVO searchSchedulerVO){
        SchedulerSeatPriceDTO schedulerSeatPriceDTO = schedulerSeatService.getSeatPriceInfo(searchSchedulerVO.getScheduleId(),searchSchedulerVO.getCinemaId());
        return ResponseUtils.sendSuccess(schedulerSeatPriceDTO);
    }

}
